<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %> 
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
  <head>
    <title>Fetch Google Contacts via OAuth</title>
  </head>
  <body>
    <h1>Fetch Google Contacts via OAuth</h1>
    
    <h2>Management</h2>
    <a href='https://www.google.com/accounts/IssuedAuthSubTokens'>Revoke access</a>
    <p>
    <a href="<c:out value='${logout}' />">Logout</a>
    <p>
        
    <%
    if (request.getAttribute("contacts") != null) {
    %>
      <h2>Contact List</h2>
      <ul>
        <c:forEach var="entry" items="${contacts}">
          <li>
          <c:out value="${entry.name}" />: <c:out value="${entry.email}" />
          </li>
        </c:forEach>
      </ul>
    <% 
    } 
    %>
    
    <% if (request.getAttribute("approval_url") != null) { %>
      Please <a href="<c:out value='${approval_url}' />">grant permission</a> to access your contacts.
    <% } %>
    
    <% if (request.getAttribute("error_code") != null) { %>
     Error code: <c:out value="${error_code}" /><p>
    <% } %>
    
    <% if (request.getAttribute("error_text") != null) { %>
     Error text:
<pre>
<c:out value="${error_text}" />
</pre>
    <% } %>

    <% if (request.getAttribute("all_data") != null) { %>
Debug information:<p>
<c:out value="${all_data}" />
<p>
    <% } %>
    
  </body>
</html>